import React,{Component} from 'react'
import Pages from '../Pages'
import CourseSmall from '../CourseSmall'
import * as pub from '../../config/public';
import * as fetch from '../../config/fetch';
class TeacherDetail extends Component {
	constructor(args) {
		super();
		this.state = {
			courseList : [],
			user:[],
			totalPage:1
		}
	}
	show(){
		fetch.teacherDetail(this.props.params.name).then((data) => {
			this.setState({
				courseList:data.userDetailCourse,
				user:data.userDetail,
				totalPage:data.total
			})
		}, (response) => {
			pub.reject(response);
		})
	}
	componentWillMount() {
		this.show()
	}
	render(){
		let user = this.state.user;
		return(
		<div className="wrapper bg-F0F4F6">
			<div className="layout clearFix">
			<div className="floatL">
			   		<div className="common-title">
						<span>讲师信息</span>
					</div>
					<div className="panel-120 bg-FFFFFF box-shadow">
						<div className="pepole-info">
							<a className="pepole-card"><i className="icon-user"></i><i className="icon-tasks"></i></a>
							<a>
							<img src={pub.getFile(user.headPath)} alt='封面图片' onError={(e) => pub.headImageError(e)} />
								<p><font>{user.userRealName}</font>{user.branckOffice}</p>
								<p>总点赞数:<span>{user.total}</span></p>
							</a>
							<p>{user.seilInformation}</p>
						</div>
					</div>
					<div className="common-title">
						<span>讲师优秀课程</span>
					</div>
					<div style={{width:'1305px'}}>
					{this.state.courseList.map((item,index)=>{
						return(
					           <div key={index}>
					             <CourseSmall id={index} course={item} show={this.show.bind(this)}/>
					           </div>
							)
					})}
					</div>
					{/*<div className="line"></div>*/}
					<Pages totaolPage={this.state.totalPage}/>
					</div>

			</div>
	    </div>
			)
	}
}
export default TeacherDetail;